package Week.Week315;

import java.util.Arrays;

public class p1 {
    class Solution {
        public int findMaxK(int[] nums) {
            Arrays.sort(nums);
            if (nums[0] >= 0){
                return -1;
            }
            int left = 0;
            int right = nums.length - 1;
            while(left < right) {
                if (nums[left] + nums[right] == 0){
                    return nums[right];
                } else if (nums[left] + nums[right] > 0){
                    right--;
                } else {
                    left++;
                }
            }
            return -1;
        }
    }
}
